package cn.nfwx.tv.controller;

import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import cn.nfwx.tv.R;
import cn.nfwx.tv.base.BaseDialogFragment;

/**
 * Created by dell on 2018/3/23.
 */

public class SceneChooseController extends BaseDialogFragment implements View.OnClickListener {
    private TextView tv_cancle_btn;
    private RelativeLayout bus_wifi, air_wifi;
    private OnAriPortClickListener onAriPortClickListener;
    private OnBusClickListener onBusClickListener;


    public static SceneChooseController newInstance() {
        SceneChooseController fragment = new SceneChooseController();

        return fragment;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_scenechoose;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        tv_cancle_btn = findView(R.id.tv_cancle_btn);
        bus_wifi = findView(R.id.bus_wifi);
        air_wifi = findView(R.id.air_wifi);
        air_wifi.setVisibility(View.INVISIBLE);
        tv_cancle_btn.setOnClickListener(this);
        bus_wifi.setOnClickListener(this);
        air_wifi.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_cancle_btn:
                dismiss();
                break;
            case R.id.air_wifi:
                onAriPortClickListener.onClick(v);
                dismiss();
                break;
            case R.id.bus_wifi:
                onBusClickListener.onClick(v);
                dismiss();
                break;
        }

    }

    /**
     * 是否填满整个屏幕
     */
    protected boolean isMatchParent() {
        return true;
    }

    protected boolean isOutsideTouchable() {
        return true;
    }

    //是否透明背景
    protected boolean isTranslucentBackground() {
        return true;
    }

    protected <T extends View> T findView(int id) {
        return (T) getView().findViewById(id);
    }


    public interface OnAriPortClickListener {
        void onClick(View view);
    }

    public void setOnAriPortClickListener(OnAriPortClickListener onAriPortClickListener) {
        this.onAriPortClickListener = onAriPortClickListener;
    }

    public interface OnBusClickListener {
        void onClick(View view);
    }

    public void setOnBusClickListener(OnBusClickListener onBusClickListener) {
        this.onBusClickListener = onBusClickListener;
    }

}
